/**
 *  @file  vsSingleton.h version 1.0 2007-11-20 
 *  @brief Definition of the class Singleton.
 *  Copyright (c) 2007 by @author <abitfree@gmail.com>
 */

#ifndef __VS_SINGLETON_H__
#define __VS_SINGLETON_H__

namespace vs
{

/**
 * @brief Template class for Singleton.
 *
 * The simplest template for Singleton, implemented by static local object in a member function.
 * The class Singleton can not be instanced, and the class TYPE must have a default constructor.
 */
template<typename TYPE>
class Singleton
{
public:
	/// Get the instance of the Singleton class.
	static TYPE& Instance()
	{
		static TYPE instance;
		return instance;
	}
private:
	// Disable instancing the template class, so it only can be instanced by the member Instance().
	Singleton();
	
	// Disable deleting the template class.
	~Singleton();
};

} // namespace vs

#endif // __VS_SINGLETON_H__
